from torch import nn


class Encoder(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, x1, valid_lens):
        raise NotImplementedError()


class Decoder(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, x2, state):
        raise NotImplementedError()


class EncoderDecoder(nn.Module):
    def __init__(self, encoder, decoder):
        super().__init__()
        self.encoder = encoder
        self.decoder = decoder

    def forward(self, x1, x2, valid_lens):
        enc_outputs = self.encoder(x1, valid_lens)
        state = (enc_outputs, valid_lens)
        return self.decoder(x2, state)
